home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Check for ring *)
- (* *)
- (* Copyright 1989, 1990 by H. Roy Engehausen. All rights reserved. *)
- (* This software may be freely distributed and used, but it may not *)
- (* under any circumstances be sold by anyone other than the author. *)
- (* It may be distributed by a commercial company as long as it is *)
- (* for no cost. *)
- (* *)
- (*===========================================================================*)
-
- PROCEDURE check_ring;
-
- VAR
- i : BYTE;
- new_tcb : tcb_ptr;
- prefix : STRING[4];
- thing : STRING[10];
-
- BEGIN;
-
-
- IF active_port^.connected^[1] <> NIL THEN
- EXIT;
-
- active_port^.modem_dial := FALSE;
-
- (*-----------------------------------------------------------------------*)
- (* Set speed as necessary *)
- (*-----------------------------------------------------------------------*)
-
- IF do_speed THEN
- BEGIN;
- do_speed := FALSE;
- IF active_port^.data_rate <> active_port^.cur_rate THEN
- FOR i := 1 TO 2 DO
- cmd_tnc(@disc_cmd, TRUE);
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Ready the display prefix *)
- (*-----------------------------------------------------------------------*)
-
- prefix := active_tcb^.port_chan_s + ' :';
- IF active_tcb^.tnc_type = t_to_h_links THEN
- prefix[3] := '-'
- ELSE
- prefix[3] := '<';
-
- (*-----------------------------------------------------------------------*)
- (* Set time out for the data *)
- (*-----------------------------------------------------------------------*)
-
- active_port^.cr_timeout := 3;
-
- (*-----------------------------------------------------------------------*)
- (* Get the data *)
- (*-----------------------------------------------------------------------*)
-
- thing := read_tnc_data_str;
-
- (*-----------------------------------------------------------------------*)
- (* Reset time out *)
- (*-----------------------------------------------------------------------*)
-
- active_port^.cr_timeout := 0;
-
- (*-----------------------------------------------------------------------*)
- (* Strip things *)
- (*-----------------------------------------------------------------------*)
-
- strip_crlf(thing);
-
- (*-----------------------------------------------------------------------*)
- (* Is phone ringing? *)
- (*-----------------------------------------------------------------------*)
-
- IF thing = ring THEN
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Switch to channel 1 *)
- (*-------------------------------------------------------------------*)
-
- active_tcb^.channel := 1;
- active_tcb^.port_chan_s[2] := '1';
-
- (*-------------------------------------------------------------------*)
- (* Create a task *)
- (*-------------------------------------------------------------------*)
-
- new_tcb := task_create(@user_start, user_stack_size);
-
- IF new_tcb <> NIL THEN
- do_speed := TRUE
- ELSE
- BEGIN;
- window_write_critical(prefix, 'Out of tasks for a ring answer');
-
- cmd_tnc(@disc_cmd, TRUE);
-
- active_port^.connected^[1] := NIL;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Switch back to channel 0 *)
- (*-------------------------------------------------------------------*)
-
- active_tcb^.channel := 0;
- active_tcb^.port_chan_s[2] := '0';
-
- (*-------------------------------------------------------------------*)
- (* Delay *)
- (*-------------------------------------------------------------------*)
-
- FOR i := 1 TO 20 DO
- task_switch;
-
- EXIT;
-
- END; (*---- End of handling ring -----------------------------*)
-
- END;